package myky.com.doctorapp.presenter;

import java.util.List;

import io.reactivex.disposables.Disposable;
import myky.com.doctorapp.entity.LoginSuccessEntity;
import myky.com.doctorapp.entity.NewConsultListBean;
import myky.com.doctorapp.base.BasePresenterIm;
import myky.com.doctorapp.base.RxSubscribe;
import myky.com.doctorapp.contract.PwLoginFragmentContract;
import myky.com.doctorapp.model.PwLoginFragmentModel;

/**
 * @author Mr.li
 */
public class PwLoginFragmentPresenter extends BasePresenterIm<PwLoginFragmentContract.View> implements PwLoginFragmentContract.Presenter {


    private PwLoginFragmentModel activityModel;

    public PwLoginFragmentPresenter() {

        activityModel=new PwLoginFragmentModel();
    }

    @Override
    public void login() {


        activityModel.login().subscribe(new RxSubscribe<LoginSuccessEntity.PayLoadBean>() {
            @Override
            protected void onSuccess(LoginSuccessEntity.PayLoadBean loginEntity) {
                    mView.loginSuccess(loginEntity);
            }

            @Override
            protected void onFailed(int code, String msg) {

            }

            @Override
            public void onSubscribe(Disposable d) {
                addSubscription(d);
            }
        });
    }

    @Override
    public void plist(String size) {
        activityModel.cgetlist(size).subscribe(new RxSubscribe<List<NewConsultListBean.PayLoadBean.SpecialistConsultsBean>>() {
            @Override
            protected void onSuccess(List<NewConsultListBean.PayLoadBean.SpecialistConsultsBean> consultsBeanList) {

                mView.vlist(consultsBeanList);
            }

            @Override
            protected void onFailed(int code, String msg) {

            }

            @Override
            public void onSubscribe(Disposable d) {

            }
        });
    }
}
